class EventEmiter{
    constructor(){
        this.cache = {}
    }

    /**
     * 
     * @param {*} type 
     * @param {*} handler 
     */
    on(type,handler){
        (this.cache[type] || (this.cache[type] = [])).push({'fn':handler})
        //this.cache[type] = handlers
        return this;
    }

    emit(type){
        let handlers = this.cache[type][0].fn
        let options = Array.prototype.slice(1).apply(arguments)
        handlers(options)
    }
}